//获取本人信息
getnative('dancool://message_getMyInfo=1');

//获取群组列表
getnative('dancool://message_getConversationList=1');

function getnative(actionurl) {
    var u = navigator.userAgent;
    var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
    var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
    if (isiOS) {
        window.webkit.messageHandlers.getnative.postMessage(actionurl);
    }else {
        ikags.getnative(actionurl)
    }
}


let userName;//本人用户id
function jsnativeresult(tag1,tag2,tag3) {

    //获取用户信息
    if (tag1 === 'dancool://message_getMyInfo=1'){
        let jsonTag3 = $.parseJSON(tag3);
        userName = jsonTag3.username
    }
    if(tag1 === 'dancool://message_getConversationList=1'){
        let jsonTag3 = $.parseJSON(tag3);
        console.log(jsonTag3);
        //群聊消息
        $('#conversationList .group').click(function () {
            let toUserName = $(this).find('.name').val();
            window.location.href = 'dancool://fullweb=https://api.odancool.com/weixinapp/view/messages/group.html?toUserName='+toUserName+'&userName='+userName
        });
    }
}